package p.ithorns.integration.transform.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import p.ithorns.integration.transform.enums.Gender;
import p.ithorns.tools.translator.annotation.field.BeanField;
import p.ithorns.tools.translator.annotation.field.ModelField;
import p.ithorns.tools.translator.annotation.meta.DictGen;
import p.ithorns.tools.translator.annotation.meta.EnumDictMeta;
import p.ithorns.tools.translator.annotation.meta.MapDictMeta;

import java.io.Serializable;

/**
 * 实体类对应的数据表为：  account
 *
 * @author ithorns
 * @date 2019-04-22 17:05:56
 */
@Getter
@Setter
@DictGen
public class Account implements Serializable {

    @TableId
    private Integer id;


    @MapDictMeta(label = "statusName", mapOf = {"0:关闭", "1:开启"})
    @ApiModelProperty(value = "状态")
    @TableField(value = "status")
    private String status;

    private Integer userId;

    @BeanField(from = "userId", bean = "userService")
    @TableField(exist = false)
    //@ModelField(from = "userId", bean = "userService", prop = "name")
    private String userName;

    @EnumDictMeta(enumOf = Gender.class)
    // @MapDictMeta(mapOf = {"1:男", "2:女"})
    @ModelField(from = "userId", bean = "userService", prop = "gender")
    @TableField(exist = false)
    private String gender;

    @Override
    public String toString() {
        return "{" +
                "status:" + status + "-" + statusName +
                ", userName:" + userName +
                ", gender:" + gender + "(" + getGenderLabel() + ")" +
                "}";
    }

}